#include<bits/stdc++.h>
using namespace std;
int a[10005];
int main(){
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 1;i <= n;i++){
		cin >> a[i];
		ans += a[i];
	}
	int l,r;
	cin >> l >> r;
	if(ans < n * l || ans > r * n){
		cout << -1;
		return 0;
	}
	int ans1 = 0;
	int ans2 = 0;
	for(int i = 1;i <= n;i++){
		if(a[i] < l){
			ans1 += l - a[i];
		}
		if(a[i] > r){
			ans2 += a[i] - r;
		}
	}
	cout << max(ans1,ans2);
}